package aip.project.controller.bio.Admin.AggiungiProdotto;

import java.util.ArrayList;
import java.util.List;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.datastore.Datastore;

import aip.project.model.ListaCategorie;
import aip.project.model.Offerte;
import aip.project.service.ListaCategorieService;
import aip.project.service.OfferteService;
import aip.project.service.RicetteService;


public class IndexController extends Controller {

    @Override
    public Navigation run() throws Exception {
        ListaCategorieService cs = new ListaCategorieService();
        RicetteService rs = new RicetteService();
        OfferteService os = new OfferteService();
        List<String[]> lc = new ArrayList<String[]>();
        for (ListaCategorie c: cs.getListaCategorie())
            lc.add(new String[] {c.getNome(),Datastore.keyToString(c.getKey())});
        requestScope("categorie",lc);
      //  List<String[]> lr = new ArrayList<String[]>();
       // for (Ricetta r: rs.getRicettaList())
         //   lr.add(new String[] {r.getNome(),Datastore.keyToString(r.getKey())});
       // requestScope("ricette",lr);
        List<String[]> lo = new ArrayList<String[]>();
        for (Offerte o: os.getOffertaList())
            lo.add(new String[] {o.getNome(),Datastore.keyToString(o.getKey())});
        requestScope("offerte",lo);
        return forward("index.jsp");
    }
}
